/**
 * @description 徽标数
 */
import React from 'react';
import classnames from "classnames";
import style from "./styles/App.less";

class App extends React.Component {
  constructor(props) {
    super(props);

    this.state = {};
  }

  render() {
    return (
      <span className={classnames("x-badge", this.props.className)} >
        {
          this.props.children
        }
        {
          this.props.hideIfCountIsZero && this.props.count <= 0 ? null : (
            this.props.count > 0 && this.props.dot ?
              <sup className="x-badge-dot"></sup> :
              <sup className="x-badge-count">
                {
                  this.props.maxCount > 0 ? (this.props.count > this.props.maxCount ? `${this.props.maxCount}+` : this.props.count) : this.props.count
                }
              </sup>
          )
        }
      </span>
    );
  }
}

App.defaultProps = {
  count: 0,
  dot: false,
  maxCount: 0,
  hideIfCountIsZero: true
};

export default App;
